from sympy import symbols, integrate, sin, cos, pi, Eq

n, m, x = symbols('n m x', integer=True, positive=True)

# 定义正交性验证函数
def verify_orthogonality(func1, func2):
    integral = integrate(func1 * func2, (x, -pi, pi))
    return Eq(integral, 0)

# 验证三种正交关系
print("1. sin(nx)与sin(mx)正交性(n≠m):", 
      verify_orthogonality(sin(n*x), sin(m*x)).simplify())

print("\n2. cos(nx)与cos(mx)正交性(n≠m):",
      verify_orthogonality(cos(n*x), cos(m*x)).simplify())

print("\n3. sin(nx)与cos(mx)正交性:",
      verify_orthogonality(sin(n*x), cos(m*x)).simplify())

print("\n4. sin(nx)与sin(nx)正交性:",
      verify_orthogonality(sin(n*x), sin(n*x)).simplify())

print("\n5. cos(nx)与cos(nx)正交性:",
      verify_orthogonality(cos(n*x), cos(n*x)).simplify())
print("\n6. sin(nx)模长:", integrate(sin(n*x)**2, (x, -pi, pi)))  # 输出π
print("7. cos(nx)模长:", integrate(cos(n*x)**2, (x, -pi, pi)))  # 输出π
